import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView //表示访问 /路径 应该显示HomeView组件
    },
    {
      path: "/detail/:storyid",//detail是路径 /:storyid动态路由参数
      //这种写法能匹配到/detail/11 /detail/999
      name: "detail",
      component:()=> import("../views/DetailView.vue")//用import导入的vue页面会单独打包异步加载

    },
    {
      path:"/comments/:storyid",
      name:"comments",
      component:()=>import("../views/CommentsView.vue")
    },
    {
      path: '/userset',
      name: 'userset',
     component:() =>import("../views/UsersetView.vue")
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue')
    }
  ]
})

export default router
